﻿using System.Collections.Generic;
using System.Data;
using DataScripter.Scripting;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DataScripter.UnitTests.Util
{
    class OutputProducerRecorder : IOutputProducer
    {
        private readonly List<string> _tablesScriptedInOrder = new List<string>();

        public void InitializeScript(IEngine engine, IScriptResult scriptResult)
        {
        }

        public void FinalizeScript()
        {
        }

        public void ProduceOutput(IDataReader reader, ITableScriptRequest tableScriptRequest)
        {
            _tablesScriptedInOrder.Add(tableScriptRequest.TableName);
        }

        public void AssertOrder(params string[] tablesExpectedInOrder)
        {
            string expectedOrder = string.Join(" ", tablesExpectedInOrder);
            string actualOrder = string.Join(" ", _tablesScriptedInOrder);
            Assert.AreEqual(expectedOrder, actualOrder, "Order");
        }
    }
}